package com.graduation.springbootinit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.graduation.springbootinit.model.entity.ActivityPart.PointsRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PointsRecordMapper extends BaseMapper<PointsRecord> {
    
    /**
     * 获取用户积分变动记录（分页）
     */
    @Select("SELECT * FROM community_activities_points_record WHERE user_id = #{userId} ORDER BY created_at DESC")
    Page<PointsRecord> selectPageByUserId(Page<PointsRecord> page, @Param("userId") Long userId);
    
    /**
     * 获取用户最近的积分变动记录
     */
    @Select("SELECT * FROM community_activities_points_record WHERE user_id = #{userId} ORDER BY created_at DESC LIMIT #{limit}")
    List<PointsRecord> selectRecentByUserId(@Param("userId") Long userId, @Param("limit") Integer limit);
} 